 package org.edu.modules.abutment.controller;

 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.xiaoymin.knife4j.annotations.ApiSort;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import java.util.Arrays;
 import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import org.apache.shiro.SecurityUtils;
 import org.edu.common.api.vo.Result;
 import org.edu.common.aspect.annotation.AutoLog;
 import org.edu.common.system.base.controller.BaseController;
 import org.edu.common.system.query.QueryGenerator;
 import org.edu.common.system.vo.LoginUser;
 import org.edu.modules.abutment.entity.VeAddonsAbutment;
 import org.edu.modules.abutment.service.IVeAddonsAbutmentService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.annotations.ApiIgnore;














 @Api(tags = {"对接登记"})
 @RestController
 @RequestMapping({"/abutment/veAddonsAbutment"})
 @ApiSort(200)
 public class VeAddonsAbutmentController
   extends BaseController<VeAddonsAbutment, IVeAddonsAbutmentService>
 {
   private static final Logger log = LoggerFactory.getLogger(org.edu.modules.abutment.controller.VeAddonsAbutmentController.class);








   @Autowired
   private IVeAddonsAbutmentService veAddonsAbutmentService;









   @AutoLog("对接登记-分页查询")
   @ApiOperation(value = "分页查询", notes = "对接登记-分页查询")
   @PostMapping({"/list"})
   @ApiImplicitParams({@ApiImplicitParam(name = "rowid", value = "关联id", required = true), @ApiImplicitParam(name = "title", value = "标题", required = false)})
   public Result<?> queryPageList(@ApiIgnore VeAddonsAbutment veAddonsAbutment, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
     QueryWrapper<VeAddonsAbutment> queryWrapper = QueryGenerator.initQueryWrapper(veAddonsAbutment, req.getParameterMap());
     Page<Map<String, Object>> page = new Page(pageNo.intValue(), pageSize.intValue());
     queryWrapper.setEntity(veAddonsAbutment);
     IPage<Map<String, Object>> pageList = this.veAddonsAbutmentService.pageMaps((IPage)page, (Wrapper)queryWrapper);
     return Result.OK(pageList);
   }







   @AutoLog("对接登记-对接情况查询")
   @ApiOperation(value = "对接情况查询", notes = "对接登记-分页查询")
   @PostMapping({"/AbutmentList"})
   @ApiImplicitParams({@ApiImplicitParam(name = "title", value = "对接名称", required = false), @ApiImplicitParam(name = "createuserid", value = "用户id,传0查当前用户", required = true)})
   public Result<?> queryAbutmentList(@ApiIgnore VeAddonsAbutment veAddonsAbutment, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
     if (veAddonsAbutment.getCreateuserid().equals(Integer.valueOf(0))) {
       LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
//      veAddonsAbutment.setCreateuserid(Integer.valueOf(sysUser.getUserId()));
     }
     QueryWrapper<VeAddonsAbutment> queryWrapper = QueryGenerator.initQueryWrapper(veAddonsAbutment, req.getParameterMap());
     Page<Map<String, Object>> page = new Page(pageNo.intValue(), pageSize.intValue());
/* 102 */     queryWrapper.setEntity(veAddonsAbutment);
     IPage<Map<String, Object>> pageList = this.veAddonsAbutmentService.selectAbutmentPage(page, (Wrapper)queryWrapper);
     return Result.OK(pageList);
   }






   @AutoLog("对接登记-通过id查询")
   @ApiOperation(value = "通过id查询", notes = "对接登记-通过id查询")
   @PostMapping({"/queryById"})
   public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
     VeAddonsAbutment veAddonsAbutment = (VeAddonsAbutment)this.veAddonsAbutmentService.getById(id);
     if (veAddonsAbutment == null) {
       return Result.error("未找到对应数据");
     }
/* 120 */     return Result.OK(veAddonsAbutment);
   }






   @AutoLog("对接登记-新增信息")
   @ApiOperation(value = "新增信息", notes = "对接登记-新增信息")
   @PostMapping({"/add"})
   public Result<?> add(@RequestBody VeAddonsAbutment veAddonsAbutment) {
     if (this.veAddonsAbutmentService.save(veAddonsAbutment)) {
/* 133 */       return Result.OK("添加成功！");
     }
     return Result.error("操作失败");
   }






   @AutoLog("对接登记-修改信息")
   @ApiOperation(value = "修改信息", notes = "对接登记-修改信息")
   @PostMapping({"/edit"})
   public Result<?> edit(@RequestBody VeAddonsAbutment veAddonsAbutment) {
     if (this.veAddonsAbutmentService.updateById(veAddonsAbutment)) {
       return Result.OK("编辑成功!");
     }
     return Result.error("操作失败");
   }


   @AutoLog("对接-结束对接")
   @PostMapping({"finish"})
   @ApiOperation(value = "设置结束", notes = "对接-结束对接")
   public Result<?> finish(@RequestParam(name = "ids", required = true) String ids) {
     if (this.veAddonsAbutmentService.changeStatusByIds(ids.split(","), 2) > 0) {
       return Result.OK("操作成功!");
     }
     return Result.error("操作失败");
   }






   @AutoLog("对接登记-通过id删除")
   @ApiOperation(value = "通过id删除", notes = "对接登记-通过id删除")
   @PostMapping({"/delete"})
   public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
     if (this.veAddonsAbutmentService.removeById(id)) {
       return Result.OK("删除成功!");
     }
/* 176 */     return Result.error("操作失败");
   }






   @AutoLog("对接登记-批量删除")
   @ApiOperation(value = "批量删除", notes = "对接登记-批量删除")
   @PostMapping({"/deleteBatch"})
   public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
     if (this.veAddonsAbutmentService.removeByIds(Arrays.asList(ids.split(",")))) {
       return Result.OK("批量删除成功!");
     }
     return Result.error("操作失败");
   }
 }


